//
//  SLTransitionContainerController.h
//  Objective-C
//
//  Created by S_Line on 2018/7/6.
//  Copyright © 2018年 S_Line. All rights reserved.
//

#import "SLBaseViewController.h"

/**
 A private UIViewControllerContextTransitioning class to be provided transitioning delegates.
 
 @discussion Because we are a custom UIViewController class, with our own containment implementation, we have to provide an object conforming to the UIViewControllerContextTransition protocol. The system view controllers use one provided by the framework, which we cannot configure, let alone create. This class will be used even if the developer provides their own transitioning objects.
 
 @note The only methods that will be called on objects of this class are the ones defined in the UIViewControllerContextTransitioning protocol. The rest is our own private implementation.
 */
@interface PrivateTransitionContext: NSObject<UIViewControllerContextTransitioning>

@property (nonatomic, copy) void (^completionBlock)(BOOL didComplete);  /// A block of code we can set to execute after baving received the completeTransition: message.
@property (nonatomic, assign, getter=isAnimated) BOOL animated;    /// Private setter for the animated property
@property (nonatomic, assign, getter=isInteractive) BOOL interactive; /// Private setter for the interactive property

/// Designated initializer
- (instancetype)initWithFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC goingRight:(BOOL)goingRight;

@end

@class SLTransitionContainerController;

@protocol SLTransitionContainerControllerDelegate<NSObject>

@optional
/**
 Informs the delegate that the user selected view controller by tapping the corresponding icon.
 
 @note The method is called regardless of whether the selected view controller changed or not and only as a result of the user tapped a button.
 The method is not called when the view controller is changed programmatically.
 This is the same pattern as UITabbarController uses.
 */
- (void)containerViewController:(SLTransitionContainerController *)containerViewController didSelectViewController:(UIViewController *)viewController;

/**
 Called on the delegate to obtain a UIViewControllerAnimatedTransitioning object which can be used to animate a non-interactive transition.
 */
- (id<UIViewControllerAnimatedTransitioning>)containerViewController:(SLTransitionContainerController *)containerController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC;

@end

@interface SLTransitionContainerController : SLBaseViewController

@property (nonatomic, weak) id<SLTransitionContainerControllerDelegate> delegate;

- (instancetype)initWithViewControllers:(NSArray *)viewControllers;

@end
